import React, { useEffect, useState } from 'react'
// 实例期 ==>
// 存在期 ==> 
// 销毁器

// useEffect() 第二个参数  监听

function Home2() {
    const [num, setNum] = useState(200)
    const [count, setCount] = useState(888)
    useEffect(() => {
        console.log('我是实例期')
        // 销毁器
        return () => {
            console.log('我要被销毁啦~~')
        }
    }, [])

    // useEffect(() => {
    //     console.log('我要执行Num的逻辑')
    // }, [num])

    // useEffect(() => {
    //     console.log('我要执行Count的逻辑')
    // }, [count])


    return (
        <div>
            Home2Home2 -- { num }
            <button onClick = {() => {
                setNum(num + 1)
            }}>++</button>

            <h3>隔开</h3>
            <div>
                Home2Home2 -- { count }
                <button onClick = {() => {
                    setCount(count + 10)
                }}>++</button>
            </div>
        </div>
    )
}

export default Home2
